package com.bill.common.system.action;

import com.bill.common.system.dto.RuleDTO;
import com.bill.common.system.service.IRuleService;
import com.opensymphony.xwork2.ActionSupport;
import com.sinba.common.dto.PageDTO;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings( "serial" )
public class RuleAction
    extends ActionSupport
{
    @Autowired
    private IRuleService ruleService;
    private PageDTO pageDTO = new PageDTO(  );
    private RuleDTO ruleDTO = new RuleDTO(  );
    private Long[] ids;
    private int page = 1;
    private int rows = 10;
    private String sord;
    private String sidx;
    private String[] ruleCode;
    private Map<String, Double> ruleMap = new HashMap<String, Double>(  );

    public PageDTO getPageDTO(  )
    {
        return pageDTO;
    }

    public void setPageDTO( PageDTO pageDTO )
    {
        this.pageDTO = pageDTO;
    }

    public RuleDTO getRuleDTO(  )
    {
        return ruleDTO;
    }

    public void setRuleDTO( RuleDTO ruleDTO )
    {
        this.ruleDTO = ruleDTO;
    }

    public Long[] getIds(  )
    {
        return ids;
    }

    public void setIds( Long[] ids )
    {
        this.ids = ids;
    }

    public int getPage(  )
    {
        return page;
    }

    public void setPage( int page )
    {
        this.page = page;
    }

    public int getRows(  )
    {
        return rows;
    }

    public void setRows( int rows )
    {
        this.rows = rows;
    }

    public String getSord(  )
    {
        return sord;
    }

    public void setSord( String sord )
    {
        this.sord = sord;
    }

    public String getSidx(  )
    {
        return sidx;
    }

    public void setSidx( String sidx )
    {
        this.sidx = sidx;
    }

    public String[] getRuleCode(  )
    {
        return ruleCode;
    }

    public void setRuleCode( String[] ruleCode )
    {
        this.ruleCode = ruleCode;
    }

    public Map<String, Double> getRuleMap(  )
    {
        return ruleMap;
    }

    public void setRuleMap( Map<String, Double> ruleMap )
    {
        this.ruleMap = ruleMap;
    }

    public String findRulePager(  )
    {
        int start = ( page - 1 ) * rows;
        ruleDTO.setStart( start );
        ruleDTO.setLimit( rows );
        pageDTO = ruleService.findRulePager( ruleDTO, sord, sidx );

        if ( pageDTO != null )
        {
            pageDTO.setPage( page );
            pageDTO.setRows( rows );
        }

        return SUCCESS;
    }

    public String saveRule(  )
    {
        ruleService.saveRule( ruleDTO );

        return SUCCESS;
    }

    public String editRule(  )
    {
        ruleService.editRule( ruleDTO );

        return SUCCESS;
    }

    public String deleteRule(  )
    {
        ruleService.deleteRule( ids );

        return SUCCESS;
    }

    public String findRuleByRuleCode(  )
    {
        ruleDTO = ruleService.findRuleByRuleCode( ruleDTO );

        return "ruleDTO";
    }

    public String findRuleMap(  )
    {
        ruleMap = ruleService.findRuleMap( ruleCode );

        return "ruleMap";
    }
    private String requestMethod;
    private String requestUri;
    private Map<String,String> requestParams = new HashMap<String, String>(); 
    private String AccessKey;
    private String AccessPassword;
    private Map<String,String> mapResult = new HashMap<String, String>(); 
    
    public String getRequestMethod() {
		return requestMethod;
	}

	public void setRequestMethod(String requestMethod) {
		this.requestMethod = requestMethod;
	}

	public String getRequestUri() {
		return requestUri;
	}

	public void setRequestUri(String requestUri) {
		this.requestUri = requestUri;
	}

	public Map<String, String> getRequestParams() {
		return requestParams;
	}

	public void setRequestParams(Map<String, String> requestParams) {
		this.requestParams = requestParams;
	}

	public String getAccessKey() {
		return AccessKey;
	}

	public void setAccessKey(String accessKey) {
		AccessKey = accessKey;
	}

	public String getAccessPassword() {
		return AccessPassword;
	}

	public void setAccessPassword(String accessPassword) {
		AccessPassword = accessPassword;
	}

	public Map<String, String> getMapResult() {
		return mapResult;
	}

	public void setMapResult(Map<String, String> mapResult) {
		this.mapResult = mapResult;
	}

}
